package com.demo.auth.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 短信码对象属性
 *
 * @author YT
 * @date 2019-06-20
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class SmsCode {

    /**
     * 短信码 String 值
     */
    private String code;

    /**
     * 短信码 过期时间
     */
    private LocalDateTime expireTime;

    public SmsCode(String code, int expireIn) {
        this.code = code;
        this.expireTime = LocalDateTime.now().plusSeconds(expireIn);
    }

    public boolean isExpire() {
        return LocalDateTime.now().isAfter(expireTime);
    }
}
